package dfs;


/**
 * 二、 二叉树的深搜
 * 1. 计算布尔二叉树的值
 * 2024-11-4
 */
public class demo6 {
    public boolean evaluateTree(TreeNode root) {
        if(root.left == null && root.right == null) return root.val != 0;

        boolean left = evaluateTree(root.left);
        boolean right = evaluateTree(root.right);
        return root.val == 2 ? left | right : left & right;
    }
}
